package one.stand.controller;

import com.jmp.autocofiguration.web.interceptor.SecurityAuthCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import one.stand.model.CompanyApplyRecordModel;
import one.stand.model.ResultModel;
import one.stand.request.CompanyCategoryModelRequest;
import one.stand.request.GoodsRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yandou on 2019/6/15.
 */
@RestController
@RequestMapping("crmPc/company/apply")
@Api(description = "经销商审核管理")
public class CompanyApplyController extends BaseController {

    /**
     * 代理产品.
     *
     * @param request
     * @return
     */
    @PostMapping("/agent")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel agentGoods(@RequestAttribute GoodsRequest request) {
        return crmFegin.agentGoods(request);
    }

    /**
     * 更新产品信息.
     */
    @PostMapping("/updateGoods")
    public ResultModel updateGoods(@RequestAttribute GoodsRequest request) {
        return crmFegin.updateGoods(request);
    }

    /**
     * 获取可代理的工厂
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "获取可代理的工厂")
    @PostMapping("/list")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel applyList(@RequestAttribute CompanyApplyRecordModel request) {
        request.setApplyCompanyId(request.getCId().intValue());
        return crmFegin.applyList(request);
    }

    /**
     * 获取经销门店
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "获取经销门店")
    @PostMapping("/supply/list")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel supplyApplylist(@RequestAttribute CompanyApplyRecordModel request) {
        return crmFegin.applySupplyList(request);
    }

    @ApiOperation(value = "获取经销分类")
    @PostMapping("/category/list")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel categoryList(@RequestAttribute CompanyCategoryModelRequest request) {
        return crmFegin.companyCategoryList(request);
    }

    @ApiOperation(value = "更新审核状态")
    @PostMapping("/updateState")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel updateState(@RequestAttribute CompanyApplyRecordModel request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.applyUpdateState(request);
    }

    @ApiOperation(value = "新增审核")
    @PostMapping("/add")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel add(@RequestAttribute CompanyApplyRecordModel request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.applyAdd(request);
    }

}
